abs() (Absolute Value)

The abs() method is used to calculate the absolute value of the number given in the brackets. As with all mathematical methods, it is used with the Math object.

syntax:

Math.abs(number)

EXAMPLE

var absValue = 456 * Math.abs(567)

document.write("The absolute value of the abs() value is : " + absValue);

The example shows a new object being declared that is the product of the multiplication of 456 and the absolute value of 567. The document.write statement then writes the value to the screen, with some descriptive text. The output should be the following:

The absolute value of the abs() value is : 258552